import request from '@/utils/request'

export default {
  getPostList(searchModel){
    return request({
      url: '/post/list',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        name: searchModel.name
      }
    })
  },
  getStudentByPostId(id) {
    return request({
      url: `/post/getStudentByPostId/${id}`,
      method: 'get'
    })
  },
  allPost() {
    return request({
      url: '/post/all',
      method: 'get',
    })
  },
  addPost(post) {
    return request({
      url: '/post',
      method: 'post',
      data: post
    })
  },
  updatePost(post) {
    return request({
      url: '/post',
      method: 'put',
      data: post
    })
  },
  savePost(post) {
    if (post.id == null && post.id === undefined) {
      return this.addPost(post)
    }
    return this.updatePost(post)
  },
  getPostById(id) {
    return request({
      url: `/post/${id}`,
      method: 'get'
    })
  },
  deletePostById(id) {
    return request({
      url: `/post/${id}`,
      method: 'delete'
    })
  }
}
